public class Login {
    public String username = "bit";
    public String password = "123";

    public void loginInfo(String username,String password) throws UserNameException{
        if(!this.username.equals(username)){
           /* System.out.println("用户名有问题");
            return;*/
            throw new UserNameException();
        }
        if(!this.password.equals(password)){
            /*System.out.println("密码有问题");
            return;*/
            throw new RuntimeException("密码有问题" + password);
        }
        System.out.println("输入登录成功");
    }

    public static void main(String[] args) throws UserNameException{
        Login login = new Login();
        /*login.loginInfo("bit","jjj");*/
        try{
            login.loginInfo("bit","jjj");
        }catch(UserNameException e){
            e.printStackTrace();
            System.out.println("捕获了异常");
        }
    }
}
